from model import GameMap
from model.Hero import Hero
from model.events.Event import Event
from view.blockImgs.EventImg import EventImg
from view.blockImgs.HeroImg import HeroImg
from view.blockImgs.StateImg import StateImg
from view.ui.GameUI import GameUI




class Stairs(Event):
    def __init__(self, x_position, y_position, direction, location):
        Event.__init__(self, x_position, y_position)
        self.direction = direction
        self.img_path = "resources/地形/stair %s.png" % direction
        EventImg(self, x_position, y_position)
        self.isWork = True
        self.location = location

    def trigger(self):
        Hero.direction = [0, 0, Hero.direction[2]]
        Hero.step = 0
        for line in GameMap.GameMap.game_map:
            for block in line:
                del block
        for img in GameUI.imgObjects:
            del img
        GameUI.imgObjects = []
        GameMap.GameMap.game_map = [[0] * 15 for i in range(21)]
        GameMap.GameMap.game_event = [[Event()] * 15 for i in range(21)]
        GameMap.GameMap.load_map(GameMap.GameMap.current_floor + self.direction)
        StateImg()
        HeroImg()
        Hero.x_location = self.location[0]
        Hero.y_location = self.location[1]
        self.isWork = False
